/*! 
 *  Simulation it's the library main class.
 *  After instantiating a simulation, physics bodies or global forces can be added,
 *  then the world can be advanced by a simulation step with update() method.
 *  -
 *  Implementation of a simple physics engine, Physics Programming course
 *  Master in Computer Game Developement, Verona, Italy
 *  -
 *  \author Andrea Casaccia
 *  \date 06 October 2012
 */

#pragma once

#include "Collisor.h"
#include "PhysicsBody.h"
#include <map>
#include <string>

namespace Pheng
{

	typedef std::map<std::string, PhysicsBody*> physicsBodiesMap;
	typedef std::map<std::string, float*> forcesMap;

	class Simulation
	{
	public:

		Simulation();
		~Simulation();

		//! Adds a rigid body to be managed by the engine
		//! \param iBodyName a label associated to the body for future retrieval
		//! \param iBody a pointer to rigid body
		//! \return void
		void addPhysicsBody( std::string, PhysicsBody* const );

		//! Adds a force that acts on all rigid bodies
		//! \param iForceName a label associated to the force for future retrieval
		//! \param iForce the vector representing the force
		//! \return void
		void addGlobalForce( std::string, float* const );

		//! Applies registered global forces to rigid bodies
		//! then updates their internal state advancing time by dt seconds
		//! \param iDt simulation step in seconds
		//! \return void
		void update( const float );

	private:
		physicsBodiesMap mPhysicsBodies;
		forcesMap mGlobalForces;
		Collisor mCollisor;

	};

}